package com.soulless;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

public class Test {

    public static void main(String[] args) throws Exception {
        // 读取Excel模板文件
        FileInputStream file = new FileInputStream("D:\\WorkSpace\\JavaCode\\soulless\\src\\main\\resources\\tmp\\tmp.xlsm");
        XSSFWorkbook workbook = new XSSFWorkbook(file);
        // 获取sheet
        XSSFSheet sheet = workbook.getSheetAt(1);


        Row row = sheet.createRow(3);
        Cell cell = row.createCell(3);
        cell.setCellValue("变更登记");

        // 保存Excel文件
        FileOutputStream outFile = new FileOutputStream("D:\\Caches\\output.xlsm");
        workbook.write(outFile);
        outFile.close();
        workbook.close();

//        List<String> dataList = new ArrayList<>();
//        // 获取要写入的行数和列数
//        int rowNum = 1; // 从第二行开始写入
//        int colNum = 0; // 第一列开始写入
//
//        // 遍历数据，逐行写入
//        for (Object data : dataList) {
//            Row row = sheet.createRow(rowNum++);
//            Cell cell = row.createCell(colNum);
//            cell.setCellValue(data.toString());
//        }
        System.out.println("-----FINISH-----");
    }

}
